import { mapActions, mapGetters } from "vuex";
import { getSessionItem, removeSessionItem } from "@/basa/utils";
export default {
  methods: {
    // 返回
    handleBack() {
      if (this.getSourceRoute()) {
        this.$router.go(-1);
      } else {
        this.$router.push("/contractManagement/contractDraft/item-list");
      }
      this.nextIsTrue();
    },

    getSourceRoute() {
      return this.getRouteUrl ?? getSessionItem("contractDraftSource", "url")
    },

    // 按钮切换
    tabBtnChange({ value }) {
      this.isFocus = value;
      if (value === "baseInfo") {
        document.documentElement.scrollTop = 0;
      } else {
        this.$refs[value].$el.scrollIntoView({
          behavior: "smooth", // 平滑过渡
          block: "start" // 上边框与视窗顶部平齐。默认值
        });
      }
    },

    nextIsTrue() {
      this.$nextTick(() => {
        this.isTrue = false;
        this.activeName = "first";
        this.isMultiShow = false;
        this.tabsSelectArr = [];
        this.uploadList = [];
        this.isShow = false;
        this.reset(); // 重置 vuex 中的值
        removeSessionItem("contractDraftSource");
      });
    },

    ...mapActions(["reset"])
  },
  computed: {
    ...mapGetters(["getRouteUrl"])
  }
};
